﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using ZkSurvey.Web.Helper;

namespace ZkSurvey.Web.WS
{
    public partial class AjaxCharaValue : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Charset = "utf-8";
            Response.Buffer = true;
            this.EnableViewState = false;
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/plain";

            int? cid = UrlHelper.GetQueryStringToInt("c");
            if (cid.HasValue)
            {
                string r = GetCharaValue(cid.Value, UrlHelper.GetQueryString("q"));
                Response.Write(r);
            }

            Response.Flush();
            Response.End();
        }

        private string GetCharaValue(int charaID, string query)
        {
            return null;
            //List<CharaValue> values = new CharaBl().GetLocalCharaValueByCharaID(charaID);
            //query = query.ToLower();
            //string[] qs = query.Split(new string[] {" "}, StringSplitOptions.RemoveEmptyEntries);
            //if (qs.Length > 0)
            //{
            //    values = values.FindAll(delegate(CharaValue v)
            //        {
            //            string code = v.Code.ToLower();
            //            foreach (string q in qs)
            //            {
            //                if (code.IndexOf(q) < 0) return false;
            //            }

            //            return true;
            //        });
            //}
            //StringBuilder sbstr = new StringBuilder();
            //sbstr.Append("[");
            //bool first = true;
            //foreach(CharaValue value in values)
            //{
            //    if (!first)
            //        sbstr.Append(",");
            //    else
            //        first = false;
            //    sbstr.Append("'" + value.Code + "'");
            //}
            //sbstr.Append("]");

            //return sbstr.ToString();
        }

    }
}
